<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>安装和运行python | 如是的学习博客</title><meta name="keywords" content="python"><meta name="author" content="rushiy"><meta name="copyright" content="rushiy"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="python官网官网：https:&#x2F;&#x2F;www.python.org&#x2F; 文档官网：https:&#x2F;&#x2F;docs.python.org&#x2F;zh-cn&#x2F;3.8&#x2F; 下载地址：https:&#x2F;&#x2F;www.python.org&#x2F;downloads&#x2F;  安装Windows安装在官网下载Windows版本的python包后，双击python.exe文件，根据图形化提示默认安装即可。需要注意的是，在安装的第一个界面中勾选下图">
<meta property="og:type" content="article">
<meta property="og:title" content="安装和运行python">
<meta property="og:url" content="https://rushiy.gitee.io/python/%E5%AE%89%E8%A3%85%E5%92%8C%E8%BF%90%E8%A1%8Cpython/index.html">
<meta property="og:site_name" content="如是的学习博客">
<meta property="og:description" content="python官网官网：https:&#x2F;&#x2F;www.python.org&#x2F; 文档官网：https:&#x2F;&#x2F;docs.python.org&#x2F;zh-cn&#x2F;3.8&#x2F; 下载地址：https:&#x2F;&#x2F;www.python.org&#x2F;downloads&#x2F;  安装Windows安装在官网下载Windows版本的python包后，双击python.exe文件，根据图形化提示默认安装即可。需要注意的是，在安装的第一个界面中勾选下图">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2022-10-17T07:59:58.000Z">
<meta property="article:author" content="rushiy">
<meta property="article:tag" content="python">
<meta name="twitter:card" content="summary"><link rel="shortcut icon" href="/img/favicon.jpg"><link rel="canonical" href="https://rushiy.gitee.io/python/%E5%AE%89%E8%A3%85%E5%92%8C%E8%BF%90%E8%A1%8Cpython/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '安装和运行python',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-11-19 01:18:40'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.3.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/img/favicon.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">28</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">3</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">如是的学习博客</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">安装和运行python</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-10-17T07:59:58.000Z" title="发表于 2022-10-17 15:59:58">2022-10-17</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-11-18T17:18:40.814Z" title="更新于 2022-11-19 01:18:40">2022-11-19</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="安装和运行python"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h2 id="python官网"><a href="#python官网" class="headerlink" title="python官网"></a>python官网</h2><p>官网：<a target="_blank" rel="noopener" href="https://www.python.org/">https://www.python.org/</a></p>
<p>文档官网：<a target="_blank" rel="noopener" href="https://docs.python.org/zh-cn/3.8/">https://docs.python.org/zh-cn/3.8/</a></p>
<p>下载地址：<a target="_blank" rel="noopener" href="https://www.python.org/downloads/">https://www.python.org/downloads/</a></p>
<p><img src="/pic/python-pic/image-20221016091935274.png" alt="image-20221016091935274"></p>
<h2 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h2><h3 id="Windows安装"><a href="#Windows安装" class="headerlink" title="Windows安装"></a>Windows安装</h3><p>在官网下载Windows版本的python包后，双击python.exe文件，根据图形化提示默认安装即可。需要注意的是，在安装的第一个界面中勾选下图中的<code>Add Python 3.8 to Path</code>，如果未勾选，则需要手动配置Python环境变量。</p>
<img src="/pic/python-pic/image-20221016092805237.png" alt="image-20221016092805237" style="zoom:67%;" />

<p>勾选上图中的<code>Add Python 3.8 to PATH</code>，实际上是在Windows系统的环境变量中添加了下面的路径信息。</p>
<img src="/pic/python-pic/image-20221016095018229.png" alt="image-20221016095018229" style="zoom:67%;" />

<blockquote>
<p>如果在安装过程中未勾选<code>Add Python 3.8 to PATH</code>，也可以手动将python的安装路径写入到Windows的环境变量即可。对于新手而言，建议直接勾选，若未勾选，可卸载已经安装好的python重新安装。</p>
<p>Windows环境变量路径：系统属性–&gt;高级–&gt;环境变量</p>
</blockquote>
<p>安装完成后，检查安装结果：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">C:\Users\rushiy&gt;python --version</span><br><span class="line">Python 3.8.6</span><br><span class="line"></span><br><span class="line">C:\Users\rushiy&gt;pip --version</span><br><span class="line">pip 20.2.1 from d:\app\tech\python\lib\site-packages\pip (python 3.8)</span><br></pre></td></tr></table></figure>

<h3 id="Linux安装"><a href="#Linux安装" class="headerlink" title="Linux安装"></a>Linux安装</h3><p>下面以CentOS为例，CentOS默认自带的python版本为2.7，python2已于 2020 年1月1日停止维护。</p>
<h4 id="yum安装"><a href="#yum安装" class="headerlink" title="yum安装"></a>yum安装</h4><p>如果可以连接外网的话，直接通过yum的方式安装即可，<strong>需要注意的是在安装和使用的过程中都需要使用<code>python3</code>，而不能直接使用python，python特指python2</strong>。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 截至2022年底，centos7自带的最新版的python为3.6.8</span></span></span><br><span class="line">yum -y install python3</span><br></pre></td></tr></table></figure>

<p>可通过<code>yum list python3</code>检查centos7系统上的python软件包</p>
<p><img src="/pic/python-pic/image-20221016102547141.png" alt="image-20221016102547141"></p>
<blockquote>
<p>看到很多网上的文章在安装python前，都按照epel-release源，但经过本人实测，epel-release源中不存在python安装包。</p>
</blockquote>
<h4 id="源码编译安装"><a href="#源码编译安装" class="headerlink" title="源码编译安装"></a>源码编译安装</h4><p>（1）下载指定版本python</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 下载</span></span></span><br><span class="line">curl -O https://www.python.org/ftp/python/3.8.15/Python-3.8.15.tgz</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 解压</span></span></span><br><span class="line">tar xzf Python-3.8.15.tgz </span><br></pre></td></tr></table></figure>

<p>（2）安装依赖包</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">yum -y groupinstall &quot;Development tools&quot;</span><br><span class="line">yum install gcc openssl-devel gcc-c++ compat-gcc-34 compat-gcc-34-c++ zlib* libffi-devel</span><br></pre></td></tr></table></figure>

<p>（3）编译安装</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cd Python-3.8.15/</span><br><span class="line">./configure --prefix=/usr/local/python-3.8.15</span><br><span class="line">make &amp;&amp; make install</span><br></pre></td></tr></table></figure>

<blockquote>
<p>参数说明：</p>
<ul>
<li><code>--prefix=/usr/local/python-3.8.15</code> 用于以结构化的方式，将 Python 安装到 <code>/usr/local/python-3.8.15</code>。</li>
<li>二进制文件在 <code>/usr/local/python-3.8.15/bin</code>；</li>
<li>头文件在 <code>/usr/local/python-3.8.15/include</code>；</li>
<li>库文件在 <code>/usr/local/python-3.8.15/lib</code>；</li>
<li>其它的资源文件在 <code>/usr/local/python-3.8.15/share</code>，如帮助文档。</li>
</ul>
<p>如果不配置 <code>--prefix</code>，安装文件将分散在多个位置：</p>
<ul>
<li>二进制文件默认在 <code>/usr/local/bin</code>；</li>
<li>头文件在 <code>/usr/local/include</code>；</li>
<li>库文件默认在 <code>/usr/local/lib</code>；</li>
<li>其它的文件在 <code>/usr/local/share</code>。</li>
</ul>
</blockquote>
<p>注意，在编译安装python的过程中，可能用到参数<code>--enable-optimizations</code> （用于优化编译），在执行<code>make</code>的过程中会报<code>Could not import runpy module</code>的错误，原因是centos默认的gcc版本是<code>4.8.5</code>，而解决此bug的版本是8。</p>
<p>（4）设置环境变量</p>
<blockquote>
<p>亦可使用软连接设置环境变量</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">echo &quot;export PATH=/usr/local/python-3.8.15/bin:\$PATH&quot; &gt;&gt; /etc/profile</span><br><span class="line">source  /etc/profile</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 检查，能正常输出如下版本信息则表明成功</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">python3 --version</span></span><br><span class="line">Python 3.8.15</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">pip3 --version</span></span><br><span class="line">pip 22.0.4 from /usr/local/python-3.8.15/lib/python3.8/site-packages/pip (python 3.8)</span><br></pre></td></tr></table></figure>

<h3 id="配置pip安装源"><a href="#配置pip安装源" class="headerlink" title="配置pip安装源"></a>配置pip安装源</h3><p>查看默认的安装源。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">pip3 config list</span></span><br><span class="line">global.index-url=&#x27;https://pypi.internal-mirrors.ucloud.cn/simple&#x27;</span><br></pre></td></tr></table></figure>

<p>安装源文件路径：</p>
<ul>
<li>linux：~&#x2F;.config&#x2F;pip&#x2F;pip.conf</li>
<li>C:\Users\UserName\AppData\Roaming\pip\pip.conf</li>
</ul>
<blockquote>
<p>注意：</p>
<p>1.UserName表示用户名</p>
<p>2.如果不存在pip和pip.conf文件，直接新建即可。</p>
</blockquote>
<h4 id="命令的方式"><a href="#命令的方式" class="headerlink" title="命令的方式"></a>命令的方式</h4><blockquote>
<p>以下以配置阿里云源的方式为例。</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 设置安装源</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">pip3 config <span class="built_in">set</span> global.index-url <span class="string">&#x27;http://mirrors.aliyun.com/pypi/simple/&#x27;</span></span></span><br><span class="line">Writing to /root/.config/pip/pip.conf</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 设置信任镜像（可选）</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">pip3 config <span class="built_in">set</span> install.trusted-host <span class="string">&#x27;mirrors.aliyun.com&#x27;</span></span></span><br><span class="line">Writing to /root/.config/pip/pip.conf</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># /root/.config/pip/pip.conf文件内容如下</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="built_in">cat</span> /root/.config/pip/pip.conf</span></span><br><span class="line">[global]</span><br><span class="line">index-url = http://mirrors.aliyun.com/pypi/simple/</span><br><span class="line"></span><br><span class="line">[install]</span><br><span class="line">trusted-host = mirrors.aliyun.com</span><br></pre></td></tr></table></figure>

<h4 id="文件写入的方式"><a href="#文件写入的方式" class="headerlink" title="文件写入的方式"></a>文件写入的方式</h4><p>亦可将设置内容直接写入<code>/root/.config/pip/pip.conf</code>文件中。</p>
<blockquote>
<p>以下以配置华为云源的方式为例。</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">[global]</span><br><span class="line">index-url = https://repo.huaweicloud.com/repository/pypi/simple</span><br><span class="line">trusted-host = repo.huaweicloud.com</span><br><span class="line">timeout = 120</span><br></pre></td></tr></table></figure>

<h3 id="python包管理工具-pip"><a href="#python包管理工具-pip" class="headerlink" title="python包管理工具-pip"></a>python包管理工具-pip</h3><p>（1）官网：<a target="_blank" rel="noopener" href="https://pypi.org/">https://pypi.org/</a></p>
<p><img src="/pic/python-pic/image-20221016111007568.png" alt="image-20221016111007568"></p>
<p>（2）官网的基本使用</p>
<ul>
<li>搜索pip软件包</li>
</ul>
<p><img src="/pic/python-pic/image-20221016103908999.png" alt="image-20221016103908999"></p>
<ul>
<li>点击<code>pip22.3</code>，进入<code>pip22.3</code>详细界面，如下，可查看软件包的安装方法和基本使用</li>
</ul>
<p><img src="/pic/python-pic/image-20221016103805036.png" alt="image-20221016103805036"></p>
<ul>
<li>当需要在内网安装软件包时，我们可以将下图中的软件包下载下来，上传到内网，再进行安装。</li>
</ul>
<p><img src="/pic/python-pic/image-20221016110931361.png" alt="image-20221016110931361"></p>
<h4 id="安装和升级pip"><a href="#安装和升级pip" class="headerlink" title="安装和升级pip"></a>安装和升级pip</h4><p>官网文档：<a target="_blank" rel="noopener" href="https://pip.pypa.io/en/stable/installation/">https://pip.pypa.io/en/stable/installation/</a></p>
<p>（1）安装</p>
<p>如果python环境中没有pip，则可以通过如下两种方式进行安装。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 方法1</span></span></span><br><span class="line">python3 -m ensurepip</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 方法2</span></span></span><br><span class="line">python3 get-pip.py</span><br></pre></td></tr></table></figure>

<p>（2）升级</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">python3 -m pip install --upgrade pip</span><br></pre></td></tr></table></figure>

<h4 id="在线和离线安装软件"><a href="#在线和离线安装软件" class="headerlink" title="在线和离线安装软件"></a>在线和离线安装软件</h4><p>（1）在线安装</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">pip3 install PackageName</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 安装特定版本的软件</span></span></span><br><span class="line">pip3 install PackageName[==version]</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 安装特定版本的软件</span></span></span><br><span class="line">pip3 install PackageName[&gt;=version]</span><br></pre></td></tr></table></figure>

<p>注意：使用<code>python -m pip install xxx</code>和<code>pip install xxx</code>效果等同，通过<code>python -m pip install xxx</code>进行软件安装是指使用python的pip模块（-m即模块的意思）进行软件安装，这两种方式都是使用了python安装目录下的<code>Scripts</code>目录中的<code>pip</code>模块。</p>
<p><img src="/pic/python-pic/image-20221016104643293.png" alt="image-20221016104643293"></p>
<p>（2）离线安装</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 首先下载模块</span></span></span><br><span class="line">pip download PackageName -d dir</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 从文件中获取包名并下载软件包</span></span></span><br><span class="line">pip download -d dir -r requirements.txt</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 离线安装</span></span></span><br><span class="line">Pip install *.whl 或 python setup.py install</span><br></pre></td></tr></table></figure>

<h4 id="升级软件包"><a href="#升级软件包" class="headerlink" title="升级软件包"></a>升级软件包</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">pip3 install -U PackageName</span><br><span class="line">pip3 install --upgrade PackageName</span><br></pre></td></tr></table></figure>

<h4 id="卸载软件包"><a href="#卸载软件包" class="headerlink" title="卸载软件包"></a>卸载软件包</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip3 uninstall PackageName</span><br></pre></td></tr></table></figure>

<h4 id="指定安装源"><a href="#指定安装源" class="headerlink" title="指定安装源"></a>指定安装源</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip3 install PackageName -i [source]</span><br></pre></td></tr></table></figure>

<h4 id="导出和导出"><a href="#导出和导出" class="headerlink" title="导出和导出"></a>导出和导出</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 将包导出requirements.txt</span></span></span><br><span class="line">pip3 freeze &gt; requirements.txt</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 安装requirements.txt文件中的所有包</span></span></span><br><span class="line">pip3 install -r requirements.txt</span><br></pre></td></tr></table></figure>

<h4 id="搜索包"><a href="#搜索包" class="headerlink" title="搜索包"></a>搜索包</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip3 search PackageName</span><br></pre></td></tr></table></figure>

<h4 id="查看包的详细信息"><a href="#查看包的详细信息" class="headerlink" title="查看包的详细信息"></a>查看包的详细信息</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip3 show [-f] PackageName</span><br></pre></td></tr></table></figure>

<blockquote>
<p>-f：会在下图输出的基础上，多输出一个files项，该项列出了与PackageName相关的文件和目录。</p>
</blockquote>
<p><img src="/pic/python-pic/image-20221016105404813.png" alt="image-20221016105404813"></p>
<h4 id="pip-list"><a href="#pip-list" class="headerlink" title="pip list"></a>pip list</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 列出已安装的包及其版本号</span></span></span><br><span class="line">pip3 list</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 查看可升级的包</span></span></span><br><span class="line">pip3 list -o</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 列出配置信息</span></span></span><br><span class="line">pip3 config list</span><br></pre></td></tr></table></figure>

<h4 id="检查包的依赖情况"><a href="#检查包的依赖情况" class="headerlink" title="检查包的依赖情况"></a>检查包的依赖情况</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip3 check PackageName</span><br></pre></td></tr></table></figure>

<h4 id="其他命令"><a href="#其他命令" class="headerlink" title="其他命令"></a>其他命令</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 查看版本</span></span></span><br><span class="line">pip3 -V</span><br><span class="line">pip3 --version</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 查看帮助信息</span></span></span><br><span class="line">pip3 -h</span><br><span class="line">pip3 --help</span><br></pre></td></tr></table></figure>

<h2 id="运行python的方式"><a href="#运行python的方式" class="headerlink" title="运行python的方式"></a>运行python的方式</h2><h3 id="交互模式下执行Python"><a href="#交互模式下执行Python" class="headerlink" title="交互模式下执行Python"></a>交互模式下执行Python</h3><p>这种模式下，直接在Python解释器的交互模式下编写对应的Python语句即可。<br>1）打开交互模式的方式：<br>       Windows下：在开始菜单找到“命令提示符”，在命令行模式输入<code>python</code> ，即可进入 Python 的交互模式；或者，在开始菜单的<code>python</code>目录下，点击目录中的的IDLE，也能进入交互模式。</p>
<p>Linux 下：直接在终端输入<code>python</code>（在centos系统下默认python是python2），如果是按装了<code>python3</code>，则直接输入<code>python3</code></p>
<p>2）在交互模式下输出：python关键字；</p>
<p>3）退出交互模式，直接输入 exit() 或者quit() 即可。<br>Windows：</p>
<ul>
<li>在命令提示符中打开交互模式</li>
</ul>
<p><img src="/pic/python-pic/image-20221017151549043.png" alt="image-20221017151549043"></p>
<ul>
<li>在IDLE中打开交互模式</li>
</ul>
<p><img src="/pic/python-pic/image-20221017151642918.png" alt="image-20221017151642918"></p>
<p>Linux：</p>
<p><img src="/pic/python-pic/image-20221017152114406.png" alt="image-20221017152114406"></p>
<h3 id="通过脚本输出"><a href="#通过脚本输出" class="headerlink" title="通过脚本输出"></a>通过脚本输出</h3><h4 id="通过python的方式运行"><a href="#通过python的方式运行" class="headerlink" title="通过python的方式运行"></a>通过python的方式运行</h4><blockquote>
<p>windows、linux、mac系统均可通过这种方式运行</p>
</blockquote>
<p>通过文本编辑器，编写脚本文件，命名为<code>hello.py</code>，在命令行模式下输入<code>python hello.py</code>即可运行。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">python hello.py</span><br></pre></td></tr></table></figure>

<blockquote>
<p>这种方式，要注意脚本文件所在路径，如果当前工作路径和脚本文件不在同一路径下，则要进入 脚本文件所在路径，或者给出脚本文件的完整路径。</p>
</blockquote>
<h4 id="通过shell脚本的方式运行"><a href="#通过shell脚本的方式运行" class="headerlink" title="通过shell脚本的方式运行"></a>通过shell脚本的方式运行</h4><p>在Linux下，还有一种运行方式，即通过shell脚本的方式运行。</p>
<p>1）添加解释器，在python文件的第一行添加<code>#!/usr/bin/env python3</code>，可通过<code>which python3</code>查看python的路径</p>
<blockquote>
<p>不建议将解释器的路径写死，通过<code>env</code>去找Python3的路径即可。</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">vim sys.py</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">!/usr/bin/env python3</span></span><br><span class="line"></span><br><span class="line">import sys</span><br><span class="line"></span><br><span class="line">print(&quot;hello, %s!&quot;%(sys.argv[1]))</span><br><span class="line">print(&quot;您好, %s!&quot;%(sys.argv[2]))</span><br></pre></td></tr></table></figure>

<p>2）修改文件权限，添加可执行权限：<code>chmod u+x hello.py</code></p>
<p>3）使用<code>./hello.py</code>运行</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">./sys.py china 中国   <span class="comment">## 运行结果如下</span></span></span><br><span class="line">hello, china!</span><br><span class="line">您好, 中国!</span><br></pre></td></tr></table></figure>

<h3 id="交互模式和脚本文件方式的比较"><a href="#交互模式和脚本文件方式的比较" class="headerlink" title="交互模式和脚本文件方式的比较"></a>交互模式和脚本文件方式的比较</h3><p>1）在交互模式下，会自动打印出运算结果，而通过脚本文件的方式不会</p>
<blockquote>
<p>以Windows为例</p>
</blockquote>
<ul>
<li>交互模式：</li>
</ul>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">python  <span class="comment"># 打开cmd，输入python</span></span><br><span class="line">Python <span class="number">3.8</span><span class="number">.6</span> (tags/v3<span class="number">.8</span><span class="number">.6</span>:db45529, Sep <span class="number">23</span> <span class="number">2020</span>, <span class="number">15</span>:<span class="number">52</span>:<span class="number">53</span>) [MSC v<span class="number">.1927</span> <span class="number">64</span> bit (AMD64)] on win32</span><br><span class="line"><span class="type">Type</span> <span class="string">&quot;help&quot;</span>, <span class="string">&quot;copyright&quot;</span>, <span class="string">&quot;credits&quot;</span> <span class="keyword">or</span> <span class="string">&quot;license&quot;</span> <span class="keyword">for</span> more information.</span><br><span class="line"><span class="meta">&gt;&gt;&gt; </span><span class="number">1</span> + <span class="number">2</span></span><br><span class="line"><span class="number">3</span></span><br><span class="line"><span class="meta">&gt;&gt;&gt; </span>exit()</span><br></pre></td></tr></table></figure>

<ul>
<li>脚本文件：没有任何输出，此时要想输出，必须使用 print 函数进行打印。</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 在sum.py文件中输入以下内容</span></span></span><br><span class="line">100 + 200</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 运行sum.py文件</span></span></span><br><span class="line">python sum.py    ## 不输出任何内容</span><br></pre></td></tr></table></figure>

<p>在脚本文件中，只有通过<code>print</code>函数才能打印结果到屏幕</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 修改sum.py文件内容，使用Print函数打印输出结果</span></span></span><br><span class="line">print(100 + 200)</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 运行sum.py文件</span></span></span><br><span class="line">python3 sum.py       ## 输出结果：300</span><br></pre></td></tr></table></figure>

<p>2）在交互模式下，每次输入的语句不会被保存，退出交互环境之后即消失，但是通过脚本文件我们可以保存我们写过的所有语句。所以通常都是通过编写脚本文件的方式来编写 Python 代码。</p>
<blockquote>
<p>注意：在编写脚本文件的时候不要使用word和windows自带的笔记本，因为他们在保存的时候会保存为utf-8 BOM格式，这会导致脚本执行错误。可以使用sublime，notepad++ , vs code等工具。</p>
</blockquote>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://rushiy.gitee.io">rushiy</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://rushiy.gitee.io/python/%E5%AE%89%E8%A3%85%E5%92%8C%E8%BF%90%E8%A1%8Cpython/">https://rushiy.gitee.io/python/%E5%AE%89%E8%A3%85%E5%92%8C%E8%BF%90%E8%A1%8Cpython/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://rushiy.gitee.io" target="_blank">如是的学习博客</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/python/">python</a></div><div class="post_share"><div class="social-share" data-image="" data-sites="wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/img/favicon.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">rushiy</div><div class="author-info__description"></div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">28</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">3</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><div class="card-info-social-icons is-center"><a class="social-icon" href="mailto:rushiy@reg.email.cn" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#python%E5%AE%98%E7%BD%91"><span class="toc-number">1.</span> <span class="toc-text">python官网</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85"><span class="toc-number">2.</span> <span class="toc-text">安装</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Windows%E5%AE%89%E8%A3%85"><span class="toc-number">2.1.</span> <span class="toc-text">Windows安装</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Linux%E5%AE%89%E8%A3%85"><span class="toc-number">2.2.</span> <span class="toc-text">Linux安装</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#yum%E5%AE%89%E8%A3%85"><span class="toc-number">2.2.1.</span> <span class="toc-text">yum安装</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%BA%90%E7%A0%81%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85"><span class="toc-number">2.2.2.</span> <span class="toc-text">源码编译安装</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%85%8D%E7%BD%AEpip%E5%AE%89%E8%A3%85%E6%BA%90"><span class="toc-number">2.3.</span> <span class="toc-text">配置pip安装源</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%91%BD%E4%BB%A4%E7%9A%84%E6%96%B9%E5%BC%8F"><span class="toc-number">2.3.1.</span> <span class="toc-text">命令的方式</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%96%87%E4%BB%B6%E5%86%99%E5%85%A5%E7%9A%84%E6%96%B9%E5%BC%8F"><span class="toc-number">2.3.2.</span> <span class="toc-text">文件写入的方式</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#python%E5%8C%85%E7%AE%A1%E7%90%86%E5%B7%A5%E5%85%B7-pip"><span class="toc-number">2.4.</span> <span class="toc-text">python包管理工具-pip</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%AE%89%E8%A3%85%E5%92%8C%E5%8D%87%E7%BA%A7pip"><span class="toc-number">2.4.1.</span> <span class="toc-text">安装和升级pip</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%9C%A8%E7%BA%BF%E5%92%8C%E7%A6%BB%E7%BA%BF%E5%AE%89%E8%A3%85%E8%BD%AF%E4%BB%B6"><span class="toc-number">2.4.2.</span> <span class="toc-text">在线和离线安装软件</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%8D%87%E7%BA%A7%E8%BD%AF%E4%BB%B6%E5%8C%85"><span class="toc-number">2.4.3.</span> <span class="toc-text">升级软件包</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%8D%B8%E8%BD%BD%E8%BD%AF%E4%BB%B6%E5%8C%85"><span class="toc-number">2.4.4.</span> <span class="toc-text">卸载软件包</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%8C%87%E5%AE%9A%E5%AE%89%E8%A3%85%E6%BA%90"><span class="toc-number">2.4.5.</span> <span class="toc-text">指定安装源</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%AF%BC%E5%87%BA%E5%92%8C%E5%AF%BC%E5%87%BA"><span class="toc-number">2.4.6.</span> <span class="toc-text">导出和导出</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%90%9C%E7%B4%A2%E5%8C%85"><span class="toc-number">2.4.7.</span> <span class="toc-text">搜索包</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B%E5%8C%85%E7%9A%84%E8%AF%A6%E7%BB%86%E4%BF%A1%E6%81%AF"><span class="toc-number">2.4.8.</span> <span class="toc-text">查看包的详细信息</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#pip-list"><span class="toc-number">2.4.9.</span> <span class="toc-text">pip list</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%A3%80%E6%9F%A5%E5%8C%85%E7%9A%84%E4%BE%9D%E8%B5%96%E6%83%85%E5%86%B5"><span class="toc-number">2.4.10.</span> <span class="toc-text">检查包的依赖情况</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%85%B6%E4%BB%96%E5%91%BD%E4%BB%A4"><span class="toc-number">2.4.11.</span> <span class="toc-text">其他命令</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%BF%90%E8%A1%8Cpython%E7%9A%84%E6%96%B9%E5%BC%8F"><span class="toc-number">3.</span> <span class="toc-text">运行python的方式</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BA%A4%E4%BA%92%E6%A8%A1%E5%BC%8F%E4%B8%8B%E6%89%A7%E8%A1%8CPython"><span class="toc-number">3.1.</span> <span class="toc-text">交互模式下执行Python</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%80%9A%E8%BF%87%E8%84%9A%E6%9C%AC%E8%BE%93%E5%87%BA"><span class="toc-number">3.2.</span> <span class="toc-text">通过脚本输出</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E9%80%9A%E8%BF%87python%E7%9A%84%E6%96%B9%E5%BC%8F%E8%BF%90%E8%A1%8C"><span class="toc-number">3.2.1.</span> <span class="toc-text">通过python的方式运行</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E9%80%9A%E8%BF%87shell%E8%84%9A%E6%9C%AC%E7%9A%84%E6%96%B9%E5%BC%8F%E8%BF%90%E8%A1%8C"><span class="toc-number">3.2.2.</span> <span class="toc-text">通过shell脚本的方式运行</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BA%A4%E4%BA%92%E6%A8%A1%E5%BC%8F%E5%92%8C%E8%84%9A%E6%9C%AC%E6%96%87%E4%BB%B6%E6%96%B9%E5%BC%8F%E7%9A%84%E6%AF%94%E8%BE%83"><span class="toc-number">3.3.</span> <span class="toc-text">交互模式和脚本文件方式的比较</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/django/Django%E6%A8%A1%E6%9D%BF%E7%B3%BB%E7%BB%9F/" title="Django模板系统"><img src="" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Django模板系统"/></a><div class="content"><a class="title" href="/django/Django%E6%A8%A1%E6%9D%BF%E7%B3%BB%E7%BB%9F/" title="Django模板系统">Django模板系统</a><time datetime="2022-11-04T07:08:03.000Z" title="发表于 2022-11-04 15:08:03">2022-11-04</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/django/Django%E8%A7%86%E5%9B%BE/" title="Django视图"><img src="" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Django视图"/></a><div class="content"><a class="title" href="/django/Django%E8%A7%86%E5%9B%BE/" title="Django视图">Django视图</a><time datetime="2022-11-03T07:07:51.000Z" title="发表于 2022-11-03 15:07:51">2022-11-03</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/django/Django%E8%B7%AF%E7%94%B1%E7%B3%BB%E7%BB%9F/" title="Django路由系统"><img src="" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Django路由系统"/></a><div class="content"><a class="title" href="/django/Django%E8%B7%AF%E7%94%B1%E7%B3%BB%E7%BB%9F/" title="Django路由系统">Django路由系统</a><time datetime="2022-11-02T07:07:34.000Z" title="发表于 2022-11-02 15:07:34">2022-11-02</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/django/%E8%B5%B0%E8%BF%9BDjango/" title="走进Django"><img src="" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="走进Django"/></a><div class="content"><a class="title" href="/django/%E8%B5%B0%E8%BF%9BDjango/" title="走进Django">走进Django</a><time datetime="2022-11-01T07:01:20.000Z" title="发表于 2022-11-01 15:01:20">2022-11-01</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/python/python%E5%B8%B8%E7%94%A8%E6%A8%A1%E5%9D%97/" title="python常用模块"><img src="" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="python常用模块"/></a><div class="content"><a class="title" href="/python/python%E5%B8%B8%E7%94%A8%E6%A8%A1%E5%9D%97/" title="python常用模块">python常用模块</a><time datetime="2022-10-28T15:34:07.000Z" title="发表于 2022-10-28 23:34:07">2022-10-28</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2022 By rushiy</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><div class="js-pjax"></div><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = false;
document.body.addEventListener('input', POWERMODE);
</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>